<template>
    <h1>编辑权限</h1>
    <div>
        <table border="1">
            <tbody>
                <tr>
                    <th>权益名称</th>
                    <th>
                        <input type="text" v-model="data.RightName">
                    </th>
                </tr>
                <tr>
                    <th>描述</th>
                    <th>
                        <input type="text" v-model="data.RightDes">
                    </th>
                </tr>
                <tr>
                    <th>状态</th>
                    <th>
                        <input type="checkbox" v-model="data.RightState">选中启用不选择禁用
                    </th>
                </tr>
                <tr>
                    <th>
                        <input type="button" value="修改" @click="Up">
                    </th>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import { reactive, ref, renderSlot } from 'vue';
import { useRouter } from 'vue-router';
import { onMounted } from 'vue';
import { useRoute } from 'vue-router';
const data=ref({
    "RightId": 0,
  "RightName": "",
  "RightDes": "",
  "RightState": true,
  "RightDelete": true
})

onMounted(()=>{
    DetailR();
})

const o=useRoute();

const DetailR=()=>{
    var val=o.query.RightId;
    axios.get("https://localhost:7147/api/Member/DetailRight",{params:{RightId:val}}).then(res=>{
        data.value=res.data;
    })
}
const roq=useRouter();
const Up=()=>{
    if(confirm('确定修改吗？')){
        axios.put("https://localhost:7147/api/Member/UpdateRight",data.value).then(res=>{
        if(res.data>0){
            alert('修改成功')
            roq.push({path:'/ShowRightView'})
        }
        else{
            alert('修改失败')
        }
    })
    }
    
}


</script>

